@extends('layouts.back_stage')
@section('content')
    <div class="container">
        <div style="padding:20px 20px 20px 0;overflow:hidden;"><h3 style="float:left;">吊牌生产列表</h3></div>
        <form action="/makeQrcode/make-code-lists" method="get">
            <div class="flow_head_box">
                <label>品牌：</label>
                <select class="address" name="brand_id" style="width: 150px;font-size:13px;">
                    <option value="" >请选择品牌</option>
                    @if(count($brands))
                        @foreach($brands as $k => $v)
                            <option value="{{$k}}" @if(isset($req->brand_id) && $req->brand_id==$k ) selected @endif >{{$v}}</option>
                        @endforeach
                    @endif
                </select>
                <label>款号：</label>
                <input type="text" style="width: 150px;display: inline-block;font-size:13px;" name="girard" value="{{$req->girard}}"
                       class="form-control" placeholder="输入款号">
                <input class="btn btn-info" style="margin-bottom:3px;" type="submit" value="搜索">
                <?php $data = Auth::guard('admin')->user()->user_role();?>
                @if(in_array('65',$data))
                <a class="btn btn-primary" style="float:right;margin-right:30px" onclick="addDrop()"
                   href="javascript:;">添加吊牌信息</a>
                @endif
            </div>
        </form>
        <table class="table" style="margin-top: 20px;">
            <thead>
            <tr>
                <th>品牌</th>
                <th>款号</th>
                <th>颜色</th>
                <th>大类</th>
                <th>中类</th>
                <th>小类</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody>
            @if(count($infos))
                @foreach($infos as $k => $v)
                <tr>
                    <td>{{$brands[$v->brand_id]}}</td>
                    <td>{{$v->girard}}</td>
                    <td>{{$v->color}}</td>
                    <td>{{$cates[$v->cate_1]}}</td>
                    <td>{{$cates[$v->cate_2]}}</td>
                    <td>{{$cates[$v->cate_3]}}</td>
                    <td>
                        @if(in_array('61',$data))   {{--仓库--}}
                        <a href="/makeQrcode/make-code-view?id={{$v->id}}&role=1">查看</a>
                        @endif
                        @if(in_array('62',$data))   {{--生产条码的人--}}
                            {{--<a href="/makeQrcode/make-code-view?id={{$v->id}}&role=1">查看</a>--}}
                        <a href="/makeQrcode/make-code-view?id={{$v->id}}&role=0">编辑</a>
                        @endif
                        @if(in_array('64',$data)) {{--生产条码的人--}}
                        <a href="JavaScript:;" onclick="deleteGoods({{$v->id}})">删除</a>
                        @endif
                    </td>
                </tr>
                @endforeach
            @endif
            </tbody>

        </table>
        <div style="float: right">
            <div style="float: right;margin:20px 0;">
                {{--<button class="btn btn-info" onclick="returnPage()" style="float:right;">跳转</button>--}}
                {{--<input type="text" class="form-control returnPage" style="width:6rem;float: right;margin:0 5px;"></div>--}}
            {{ $infos->appends(['brand_id'=>$req->brand_id,'girard'=>$req->girard])->links() }}
        </div>
    </div>
    <script>
        /*添加吊牌信息*/
        function addDrop() {
            $.ajax({
                headers: {
                    'X-CSRF-TOKEN': $('meta[name="csrf_token"]').attr('content')
                },

                url:'/makeQrcode/increase-qrcode-info',
                type:'post',
                data:{},
                dataType:'json',
                success:function (data) {
                    if(data.result.success){
                        window.location.href='/makeQrcode/make-code-view?id='+data.content+'&role=0';
                    }else{
                        $(".faceImg").attr("src","/img/weep.png");
                        $(".oHandle").text(data.result.errorMsg);
                        $(".oSuccess").show(0).delay(1000).hide(0);
                    }
                }
            })
        }
        /*删除*/
        function deleteGoods(id){
            $(".oText").text("确定要删除吗？");
            $(".oMask").show();
            $(".oAnim").show();
            $(".oBtn0").attr("abc",id);
            $(".oBtn0").attr('id','');
            $(".oBtn0").attr('id','delDrop');
        }
        /*点确定*/
        $(document).on('click','#delDrop',function(){
            $(".oMask").hide();
            $(".oAnim").hide();
            var id=$(this).attr("abc");
            $.ajax({
                headers: {
                    'X-CSRF-TOKEN': $('meta[name="csrf_token"]').attr('content')
                },
                type:'post',
                url:'/makeQrcode/qrcode-generate-del',
                data:{
                    'id':id
                },
                dataType:'json',
                success:function (data) {
                    if(data.result.success){
                        $(".faceImg").attr("src","/img/laugh.png");
                        $(".oHandle").text("删除成功");
                        $(".oSuccess").show(0).delay(1000).hide(0);
                        window.location.reload();
                    }else{
                        $(".faceImg").attr("src","/img/weep.png");
                        $(".oHandle").text(data.result.errorMsg);
                        $(".oSuccess").show(0).delay(1000).hide(0);
                    }
                }
            });
        });
    </script>
@endsection